﻿using ChestPainCenterSystem.Core;
using ChestPainCenterSystem.ThreeCenterManage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ChestPainCenterSystem.Code.Bll
{
    /// <summary>
    /// 绿色通道相关
    /// </summary>
    public class GreenChannelManager
    {
        /// <summary>
        /// 开启患者绿色通道
        /// </summary>
        /// <param name="patientId">患者ID</param>
        /// <param name="isGreenChannel">开启ID 0=>关闭 1=>开启</param>
        /// <returns></returns>
        public static OperateResult StartGreenChannel(string patientId, int isGreenChannel)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ThreeCenterManageSoapClient service = new ThreeCenterManageSoapClient();
                ResultHelperOfBoolean result = service.StartGreenChannel(patientId, isGreenChannel);
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.M;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }




        /// <summary>
        ///  批量审批患者绿色通道
        /// </summary>
        /// <param name="approvalJson"></param>
        /// <returns></returns>
        public static OperateResult BatchApprChannel(string approvalJson)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ThreeCenterManageSoapClient service = new ThreeCenterManageSoapClient();
                ResultHelperOfBoolean result = service.BatchApprChannel(approvalJson);
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.M;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }

        /// <summary>
        /// 加载数据 审批列表
        /// </summary>
        /// <returns></returns>
        public static OperateResult GetGreenChannelPatient(int pageIndex, int pageSize, string patientName, int approvalStatus)
        {
            OperateResult resultInfo = new OperateResult();
            try
            {
                ThreeCenterManageSoapClient service = new ThreeCenterManageSoapClient();
                ResultHelperOfString result = service.GetGreenChannelPatient(patientName, approvalStatus, pageIndex, pageSize);
                if (result.S)
                {
                    resultInfo.Result = 1;
                    resultInfo.Body = result.D;
                }
                else
                {
                    resultInfo.Result = 0;
                    resultInfo.Body = result.M;
                }
            }
            catch (Exception ex)
            {
                resultInfo.Result = -1;
                resultInfo.Body = ex.Message;
            }
            return resultInfo;
        }
    }
}